package com.wch.sqlSession;

import com.wch.config.XMLConfigBuilder;
import com.wch.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder{
    public SqlSessionFactory build(InputStream inputStream) throws DocumentException, PropertyVetoException {
        //使用dom4j解析配置文件，将解析的文件封装到Configuration
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        DefultSqlSessionFactory defaultSqlSessionFactory = new DefultSqlSessionFactory(configuration);
        return defaultSqlSessionFactory;
    }
}
